package com.example.demo.service.service.impl;

import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import com.example.demo.dao.dao.UserDAO;
import com.example.demo.service.dto.UserDTO;
import com.example.demo.service.dto.mapper.UserMapper;
import com.example.demo.service.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private UserDAO userDAO;

    @Override
    public List<UserDTO> query() {
        return new LambdaQueryChainWrapper<>(userDAO).list().stream()
                .map(UserMapper.INSTANCE::entityUserToUserDTO).collect(Collectors.toList());
    }
}
